#include "Movable.h"
#include <math.h>
using namespace Physics;
using namespace Math;

Movable::Movable(float speed, float acceleration):_speed(speed),_acceleration(acceleration)
{
}

const float Movable::speed() const
{
	return _speed;
}

const float Movable::acceleration() const
{
	return _acceleration;
}

void Movable::setSpeed(float speed)
{
	_speed=speed;
}

void Movable::setAcceleration(float acceleration)
{
	_acceleration=acceleration;
}

Vector Movable::travel()
{
	_speed*=_acceleration;

	if (_speed<0.0005f)
		_speed=0.0f;

	return _direction.unit()*fabs(_speed);
}

Vector Movable::direction() const
{
	return _direction;
}

void Movable::setDirection(const Vector& d)
{
	_direction=d;
}
